home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Explosion
/
Software Explosion (Fore-Matt Home Computing)(1996).iso
/
games
/
workbench
/
lander_2
/
source
/
cleanup.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-01
|
631b
|
39 lines
#include <exec/memory.h>
struct _clean {
int (*function)();
char *name;
struct _clean *next;
} *cleanlist = NULL;
add_cleanup(function, name)
int (*function)();
{
struct _clean *ptr;
ptr = AllocMem(sizeof(struct _clean), MEMF_PUBLIC);
if(!ptr)
return 0;
ptr->function = function;
ptr->name = name;
ptr->next = cleanlist;
cleanlist = ptr;
}
cleanup(debug)
int debug;
{
struct _clean *ptr;
int (*f)();
while(cleanlist) {
ptr = cleanlist;
cleanlist = cleanlist->next;
f = ptr->function;
if(debug == 1)
printf("Cleanup: removing '%s'\n", ptr->name);
FreeMem(ptr, sizeof(struct _clean));
(*f)();
}
}